package org.shj.xiti

import scala.collection.mutable.ArrayBuffer

//#两个 3 行 3 列的矩阵，实现其对应位置的数据相加，并返回一个新矩阵：
object T044 {
  def main(args: Array[String]): Unit = {
    val x = Array(Array(12,7,3), Array(4,5,6), Array(7,8,9))
    val y = Array(Array(5,8,1), Array(6,7,3), Array(4,5,9))
    
    x.zip(y)
    
    val z = Array.ofDim[Int](3, 3)
    
    for(i <- 0 to x.length-1){
      for(j <- 0 to x(i).length-1){
        //println(x(i)(j))
        z(i)(j) = x(i)(j) + y(i)(j)
      }
    }
    z.foreach(item => {
      item.foreach(print)
      println
    })
  }
}